<!--
**********************************************************
* @Author: 张小平
* @Date:   2024-05-01
* @Email:  qqshuqian@163.com
* @Last modified: 最后修改日期
* @Description: 文件描述
**********************************************************
-->
<template>
  <component
  :is="typeComponent"
  :item="item"
  @on-del="handleDel"
  @on-save="handleSave" />
</template>

<script>
import _ from 'lodash'
import {
  ItemNumber,
  ItemSelect,
  ItemRadio,
} from './index'

export default {
  props: {
    item: {
      type: Object,
      default: () => {}
    }
  },
  components: {
    ItemNumber,
    ItemSelect,
    ItemRadio,
  },
  computed: {
    typeComponent() {
      const {
        dataType
      } = this.item
      return `Item${_.upperFirst(dataType)}`
    }
  },
  methods: {
    handleDel(item) {
      this.$emit('on-del', item)
    },
    handleSave(item) {
      this.$emit('on-save', item)
    }
  }
}
</script>
